<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<!--      <el-form-item label="单位" prop="company">-->
<!--        <el-input-->
<!--          v-model="queryParams.company"-->
<!--          placeholder="请输入单位"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="身份证号" prop="idCardNumber">
        <el-input
          v-model="queryParams.idCardNumber"
          placeholder="请输入身份证号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="性别" prop="gender">-->
<!--        <el-input-->
<!--          v-model="queryParams.gender"-->
<!--          placeholder="请输入性别"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="出生年月" prop="birthDate">-->
<!--        <el-date-picker clearable-->
<!--          v-model="queryParams.birthDate"-->
<!--          type="date"-->
<!--          value-format="yyyy-MM-dd"-->
<!--          placeholder="请选择出生年月">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="参加工作时间" prop="startWorkDate">-->
<!--        <el-date-picker clearable-->
<!--          v-model="queryParams.startWorkDate"-->
<!--          type="date"-->
<!--          value-format="yyyy-MM-dd"-->
<!--          placeholder="请选择参加工作时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="学位" prop="degree">-->
<!--        <el-input-->
<!--          v-model="queryParams.degree"-->
<!--          placeholder="请输入学位"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="技术职务职称" prop="technicalTitle">-->
<!--        <el-input-->
<!--          v-model="queryParams.technicalTitle"-->
<!--          placeholder="请输入技术职务职称"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="资格证工种借调人员" prop="qualificationCertificate">-->
<!--        <el-input-->
<!--          v-model="queryParams.qualificationCertificate"-->
<!--          placeholder="请输入资格证工种借调人员"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="用工性质" prop="employmentNature">-->
<!--        <el-input-->
<!--          v-model="queryParams.employmentNature"-->
<!--          placeholder="请输入用工性质"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="岗位" prop="position">-->
<!--        <el-input-->
<!--          v-model="queryParams.position"-->
<!--          placeholder="请输入岗位"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="岗位工资" prop="positionSalary">-->
<!--        <el-input-->
<!--          v-model="queryParams.positionSalary"-->
<!--          placeholder="请输入岗位工资"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="社会保障号" prop="socialSecurityNumber">-->
<!--        <el-input-->
<!--          v-model="queryParams.socialSecurityNumber"-->
<!--          placeholder="请输入社会保障号"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="民族" prop="ethnicity">-->
<!--        <el-input-->
<!--          v-model="queryParams.ethnicity"-->
<!--          placeholder="请输入民族"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="文化程度" prop="educationLevel">-->
<!--        <el-input-->
<!--          v-model="queryParams.educationLevel"-->
<!--          placeholder="请输入文化程度"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="曾用名" prop="formerName">-->
<!--        <el-input-->
<!--          v-model="queryParams.formerName"-->
<!--          placeholder="请输入曾用名"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="入党时间" prop="partyJoinDate">-->
<!--        <el-date-picker clearable-->
<!--          v-model="queryParams.partyJoinDate"-->
<!--          type="date"-->
<!--          value-format="yyyy-MM-dd"-->
<!--          placeholder="请选择入党时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
      <el-form-item label="家庭住址" prop="homeAddress">
        <el-input
          v-model="queryParams.homeAddress"
          placeholder="请输入家庭住址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="出生地" prop="birthPlace">-->
<!--        <el-input-->
<!--          v-model="queryParams.birthPlace"-->
<!--          placeholder="请输入出生地"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="籍贯" prop="nativePlace">-->
<!--        <el-input-->
<!--          v-model="queryParams.nativePlace"-->
<!--          placeholder="请输入籍贯"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="户口所在地" prop="householdRegister">-->
<!--        <el-input-->
<!--          v-model="queryParams.householdRegister"-->
<!--          placeholder="请输入户口所在地"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="劳动合同订立情况" prop="laborContract">
        <el-input
          v-model="queryParams.laborContract"
          placeholder="请输入劳动合同订立情况"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="档案编号" prop="fileNumber">
        <el-input
          v-model="queryParams.fileNumber"
          placeholder="请输入档案编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="劳务工单位" prop="laborServiceUnit">-->
<!--        <el-input-->
<!--          v-model="queryParams.laborServiceUnit"-->
<!--          placeholder="请输入劳务工单位"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="毕业院校" prop="graduationSchool">-->
<!--        <el-input-->
<!--          v-model="queryParams.graduationSchool"-->
<!--          placeholder="请输入毕业院校"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="毕业时间" prop="graduationDate">-->
<!--        <el-date-picker clearable-->
<!--          v-model="queryParams.graduationDate"-->
<!--          type="date"-->
<!--          value-format="yyyy-MM-dd"-->
<!--          placeholder="请选择毕业时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="所学专业" prop="major">-->
<!--        <el-input-->
<!--          v-model="queryParams.major"-->
<!--          placeholder="请输入所学专业"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="配偶姓名" prop="spouseName">-->
<!--        <el-input-->
<!--          v-model="queryParams.spouseName"-->
<!--          placeholder="请输入配偶姓名"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="配偶单位" prop="spouseUnit">-->
<!--        <el-input-->
<!--          v-model="queryParams.spouseUnit"-->
<!--          placeholder="请输入配偶单位"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="配偶家属电话" prop="spousePhoneNumber">-->
<!--        <el-input-->
<!--          v-model="queryParams.spousePhoneNumber"-->
<!--          placeholder="请输入配偶家属电话"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="本人手机号" prop="personalPhoneNumber">
        <el-input
          v-model="queryParams.personalPhoneNumber"
          placeholder="请输入本人手机号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="年龄" prop="age">-->
<!--        <el-input-->
<!--          v-model="queryParams.age"-->
<!--          placeholder="请输入年龄"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="备注" prop="remarks">-->
<!--        <el-input-->
<!--          v-model="queryParams.remarks"-->
<!--          placeholder="请输入备注"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="编号" prop="number">-->
<!--        <el-input-->
<!--          v-model="queryParams.number"-->
<!--          placeholder="请输入编号"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="当兵" prop="militaryService">-->
<!--        <el-input-->
<!--          v-model="queryParams.militaryService"-->
<!--          placeholder="请输入当兵"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="民主党派" prop="democraticParty">-->
<!--        <el-input-->
<!--          v-model="queryParams.democraticParty"-->
<!--          placeholder="请输入民主党派"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="工作单位二级" prop="secondaryWorkUnit">
        <el-input
          v-model="queryParams.secondaryWorkUnit"
          placeholder="请输入工作单位二级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="工作单位三级" prop="tertiaryWorkUnit">-->
<!--        <el-input-->
<!--          v-model="queryParams.tertiaryWorkUnit"-->
<!--          placeholder="请输入工作单位三级"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="员工号合同编号" prop="employeeNumberContractNumber">
        <el-input
          v-model="queryParams.employeeNumberContractNumber"
          placeholder="请输入员工号合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="业绩成果等级文件上传" prop="performanceAchievementLevelUpload">-->
<!--        <el-input-->
<!--          v-model="queryParams.performanceAchievementLevelUpload"-->
<!--          placeholder="请输入业绩成果等级文件上传"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['archives:archives:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['archives:archives:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['archives:archives:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['archives:archives:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
        >导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="archivesList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="单位" align="center" prop="company" />
      <el-table-column label="身份证号" align="center" prop="idCardNumber" />
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="性别" align="center" prop="gender" />
      <el-table-column label="出生年月" align="center" prop="birthDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.birthDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="参加工作时间" align="center" prop="startWorkDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startWorkDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="学位" align="center" prop="degree" />
      <el-table-column label="技术职务职称" align="center" prop="technicalTitle" />
      <el-table-column label="资格证工种借调人员" align="center" prop="qualificationCertificate" />
      <el-table-column label="用工性质" align="center" prop="employmentNature" />
      <el-table-column label="岗位" align="center" prop="position" />
      <el-table-column label="岗位工资" align="center" prop="positionSalary" />
      <el-table-column label="社会保障号" align="center" prop="socialSecurityNumber" />
      <el-table-column label="民族" align="center" prop="ethnicity" />
      <el-table-column label="文化程度" align="center" prop="educationLevel" />
      <el-table-column label="曾用名" align="center" prop="formerName" />
      <el-table-column label="政治面貌" align="center" prop="politicalStatus" />
      <el-table-column label="入党时间" align="center" prop="partyJoinDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.partyJoinDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="家庭住址" align="center" prop="homeAddress" />
      <el-table-column label="出生地" align="center" prop="birthPlace" />
      <el-table-column label="籍贯" align="center" prop="nativePlace" />
      <el-table-column label="户口所在地" align="center" prop="householdRegister" />
      <el-table-column label="血型" align="center" prop="bloodType" />
      <el-table-column label="劳动合同订立情况" align="center" prop="laborContract" />
      <el-table-column label="档案编号" align="center" prop="fileNumber" />
      <el-table-column label="劳务工单位" align="center" prop="laborServiceUnit" />
      <el-table-column label="毕业院校" align="center" prop="graduationSchool" />
      <el-table-column label="毕业时间" align="center" prop="graduationDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.graduationDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="所学专业" align="center" prop="major" />
      <el-table-column label="配偶姓名" align="center" prop="spouseName" />
      <el-table-column label="配偶单位" align="center" prop="spouseUnit" />
      <el-table-column label="配偶家属电话" align="center" prop="spousePhoneNumber" />
      <el-table-column label="本人手机号" align="center" prop="personalPhoneNumber" />
      <el-table-column label="年龄" align="center" prop="age" />
      <el-table-column label="备注" align="center" prop="remarks" />
      <el-table-column label="编号" align="center" prop="number" />
      <el-table-column label="当兵" align="center" prop="militaryService" />
      <el-table-column label="民主党派" align="center" prop="democraticParty" />
      <el-table-column label="工作单位二级" align="center" prop="secondaryWorkUnit" />
      <el-table-column label="工作单位三级" align="center" prop="tertiaryWorkUnit" />
      <el-table-column label="员工号合同编号" align="center" prop="employeeNumberContractNumber" />
      <el-table-column label="业绩成果等级文件上传" align="center" prop="performanceAchievementLevelUpload" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['archives:archives:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['archives:archives:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改员工档案对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="序号" prop="id">
          <el-input v-model="form.id" placeholder="请输入序号" />
        </el-form-item>
        <el-form-item label="单位" prop="company">
          <el-input v-model="form.company" placeholder="请输入单位" />
        </el-form-item>
        <el-form-item label="身份证号" prop="idCardNumber">
          <el-input v-model="form.idCardNumber" placeholder="请输入身份证号" />
        </el-form-item>
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="性别" prop="gender">
          <el-input v-model="form.gender" placeholder="请输入性别" />
        </el-form-item>
        <el-form-item label="出生年月" prop="birthDate">
          <el-date-picker clearable
            v-model="form.birthDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择出生年月">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="参加工作时间" prop="startWorkDate">
          <el-date-picker clearable
            v-model="form.startWorkDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择参加工作时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="学位" prop="degree">
          <el-input v-model="form.degree" placeholder="请输入学位" />
        </el-form-item>
        <el-form-item label="技术职务职称" prop="technicalTitle">
          <el-input v-model="form.technicalTitle" placeholder="请输入技术职务职称" />
        </el-form-item>
        <el-form-item label="资格证工种借调人员" prop="qualificationCertificate">
          <el-input v-model="form.qualificationCertificate" placeholder="请输入资格证工种借调人员" />
        </el-form-item>
        <el-form-item label="用工性质" prop="employmentNature">
          <el-input v-model="form.employmentNature" placeholder="请输入用工性质" />
        </el-form-item>
        <el-form-item label="岗位" prop="position">
          <el-input v-model="form.position" placeholder="请输入岗位" />
        </el-form-item>
        <el-form-item label="岗位工资" prop="positionSalary">
          <el-input v-model="form.positionSalary" placeholder="请输入岗位工资" />
        </el-form-item>
        <el-form-item label="社会保障号" prop="socialSecurityNumber">
          <el-input v-model="form.socialSecurityNumber" placeholder="请输入社会保障号" />
        </el-form-item>
        <el-form-item label="民族" prop="ethnicity">
          <el-input v-model="form.ethnicity" placeholder="请输入民族" />
        </el-form-item>
        <el-form-item label="文化程度" prop="educationLevel">
          <el-input v-model="form.educationLevel" placeholder="请输入文化程度" />
        </el-form-item>
        <el-form-item label="曾用名" prop="formerName">
          <el-input v-model="form.formerName" placeholder="请输入曾用名" />
        </el-form-item>
        <el-form-item label="入党时间" prop="partyJoinDate">
          <el-date-picker clearable
            v-model="form.partyJoinDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择入党时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="家庭住址" prop="homeAddress">
          <el-input v-model="form.homeAddress" placeholder="请输入家庭住址" />
        </el-form-item>
        <el-form-item label="出生地" prop="birthPlace">
          <el-input v-model="form.birthPlace" placeholder="请输入出生地" />
        </el-form-item>
        <el-form-item label="籍贯" prop="nativePlace">
          <el-input v-model="form.nativePlace" placeholder="请输入籍贯" />
        </el-form-item>
        <el-form-item label="户口所在地" prop="householdRegister">
          <el-input v-model="form.householdRegister" placeholder="请输入户口所在地" />
        </el-form-item>
        <el-form-item label="劳动合同订立情况" prop="laborContract">
          <el-input v-model="form.laborContract" placeholder="请输入劳动合同订立情况" />
        </el-form-item>
        <el-form-item label="档案编号" prop="fileNumber">
          <el-input v-model="form.fileNumber" placeholder="请输入档案编号" />
        </el-form-item>
        <el-form-item label="劳务工单位" prop="laborServiceUnit">
          <el-input v-model="form.laborServiceUnit" placeholder="请输入劳务工单位" />
        </el-form-item>
        <el-form-item label="毕业院校" prop="graduationSchool">
          <el-input v-model="form.graduationSchool" placeholder="请输入毕业院校" />
        </el-form-item>
        <el-form-item label="毕业时间" prop="graduationDate">
          <el-date-picker clearable
            v-model="form.graduationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择毕业时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="所学专业" prop="major">
          <el-input v-model="form.major" placeholder="请输入所学专业" />
        </el-form-item>
        <el-form-item label="配偶姓名" prop="spouseName">
          <el-input v-model="form.spouseName" placeholder="请输入配偶姓名" />
        </el-form-item>
        <el-form-item label="配偶单位" prop="spouseUnit">
          <el-input v-model="form.spouseUnit" placeholder="请输入配偶单位" />
        </el-form-item>
        <el-form-item label="配偶家属电话" prop="spousePhoneNumber">
          <el-input v-model="form.spousePhoneNumber" placeholder="请输入配偶家属电话" />
        </el-form-item>
        <el-form-item label="本人手机号" prop="personalPhoneNumber">
          <el-input v-model="form.personalPhoneNumber" placeholder="请输入本人手机号" />
        </el-form-item>
        <el-form-item label="年龄" prop="age">
          <el-input v-model="form.age" placeholder="请输入年龄" />
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input v-model="form.remarks" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="编号" prop="number">
          <el-input v-model="form.number" placeholder="请输入编号" />
        </el-form-item>
        <el-form-item label="当兵" prop="militaryService">
          <el-input v-model="form.militaryService" placeholder="请输入当兵" />
        </el-form-item>
        <el-form-item label="民主党派" prop="democraticParty">
          <el-input v-model="form.democraticParty" placeholder="请输入民主党派" />
        </el-form-item>
        <el-form-item label="工作单位二级" prop="secondaryWorkUnit">
          <el-input v-model="form.secondaryWorkUnit" placeholder="请输入工作单位二级" />
        </el-form-item>
        <el-form-item label="工作单位三级" prop="tertiaryWorkUnit">
          <el-input v-model="form.tertiaryWorkUnit" placeholder="请输入工作单位三级" />
        </el-form-item>
        <el-form-item label="员工号合同编号" prop="employeeNumberContractNumber">
          <el-input v-model="form.employeeNumberContractNumber" placeholder="请输入员工号合同编号" />
        </el-form-item>
        <el-form-item label="业绩成果等级文件上传" prop="performanceAchievementLevelUpload">
          <el-input v-model="form.performanceAchievementLevelUpload" placeholder="请输入业绩成果等级文件上传" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 档案导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listArchives, getArchives, delArchives, addArchives, updateArchives } from "@/api/archives/archives";
import { getToken } from "@/utils/auth";
// 导入模板接口importTemplate
// import { importTemplate } from "@/api/system/user";
// import { importTemplate } from "@/api/archives/archives";
export default {
  name: "Archives",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 员工档案表格数据
      archivesList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        company: null,
        idCardNumber: null,
        name: null,
        gender: null,
        birthDate: null,
        startWorkDate: null,
        degree: null,
        technicalTitle: null,
        qualificationCertificate: null,
        employmentNature: null,
        position: null,
        positionSalary: null,
        socialSecurityNumber: null,
        ethnicity: null,
        educationLevel: null,
        formerName: null,
        politicalStatus: null,
        partyJoinDate: null,
        homeAddress: null,
        birthPlace: null,
        nativePlace: null,
        householdRegister: null,
        bloodType: null,
        laborContract: null,
        fileNumber: null,
        laborServiceUnit: null,
        graduationSchool: null,
        graduationDate: null,
        major: null,
        spouseName: null,
        spouseUnit: null,
        spousePhoneNumber: null,
        personalPhoneNumber: null,
        age: null,
        remarks: null,
        number: null,
        militaryService: null,
        democraticParty: null,
        secondaryWorkUnit: null,
        tertiaryWorkUnit: null,
        employeeNumberContractNumber: null,
        performanceAchievementLevelUpload: null
      },

      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/archives/archives/importData"
      },

      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询员工档案列表 */
    getList() {
      this.loading = true;
      listArchives(this.queryParams).then(response => {
        this.archivesList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        company: null,
        idCardNumber: null,
        name: null,
        gender: null,
        birthDate: null,
        startWorkDate: null,
        degree: null,
        technicalTitle: null,
        qualificationCertificate: null,
        employmentNature: null,
        position: null,
        positionSalary: null,
        socialSecurityNumber: null,
        ethnicity: null,
        educationLevel: null,
        formerName: null,
        politicalStatus: null,
        partyJoinDate: null,
        homeAddress: null,
        birthPlace: null,
        nativePlace: null,
        householdRegister: null,
        bloodType: null,
        laborContract: null,
        fileNumber: null,
        laborServiceUnit: null,
        graduationSchool: null,
        graduationDate: null,
        major: null,
        spouseName: null,
        spouseUnit: null,
        spousePhoneNumber: null,
        personalPhoneNumber: null,
        age: null,
        remarks: null,
        number: null,
        militaryService: null,
        democraticParty: null,
        secondaryWorkUnit: null,
        tertiaryWorkUnit: null,
        employeeNumberContractNumber: null,
        performanceAchievementLevelUpload: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加员工档案";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getArchives(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改员工档案";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateArchives(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addArchives(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除员工档案编号为"' + ids + '"的数据项？').then(function() {
        return delArchives(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('archives/archives/export', {
        ...this.queryParams
      }, `archives_${new Date().getTime()}.xlsx`)
    },

    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "用户导入";
      this.upload.open = true;
    },
    // /** 下载模板操作 */
    // importTemplate() {
    //   importTemplate().then(response => {
    //     this.download(response.msg);
    //   });
    // },
    /** 下载模板操作 */
    importTemplate() {
      this.download('archives/archives/importTemplate', {
      }, `archives_template_${new Date().getTime()}.xlsx`)
    },
// 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
// 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
// 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    }
  }
};
</script>
